package sgt.supermarket.hibernatedao;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;

public class HibernateDAOFactory {

    private static Log log = LogFactory.getLog(HibernateDAOFactory.class);
    /**
     * Creates a standalone IDAOFactory that returns unmanaged DAO
     * beans for use in any environment Hibernate has been configured
     * for. Uses HibernateUtil/SessionFactory and Hibernate context
     * propagation (CurrentSessionContext), thread-bound or transaction-bound,
     * and transaction scoped.
     */
    public static final Class HIBERNATE = HibernateDAOFactory.class;
    /**
     * Factory method for instantiation of concrete factories.
     */
    private Session session;

    public HibernateDAOFactory() {
        this(HibernateSessionProvider.getNewSession());
    }

    public HibernateDAOFactory(Session session) {
        this.session = session;
    }

    public HibernateProductDAO getProductDAO() {
        return new HibernateProductDAO(session);
    }

    public HibernateRoleDAO getRoleDAO() {
        return new HibernateRoleDAO(session);
    }

    public HibernateEmployeeDAO getEmployeeDAO() {
        return new HibernateEmployeeDAO(session);
    }


    public HibernateCustomerDAO getCustomerDAO(){
        return new HibernateCustomerDAO(session);
    }


    public HibernateInvoiceDAO getInvoiceDAO() {
        return new HibernateInvoiceDAO(session);
    }

    public HibernateCategoryDAO getCategoryDAO() {
        return new HibernateCategoryDAO(session);
    }

    public HibernateInvoiceItemDAO getInvoiceItemDAO(){
        return new HibernateInvoiceItemDAO(session);
    }

    public HibernateProductBlockDAO getProductBlockDAO() {
        return new HibernateProductBlockDAO(session);
    }

    public HibernateSaleProgramDAO getSaleProgramDAO() {
        return new HibernateSaleProgramDAO(session);
    }
}
